/****************************************************
*	OSMF Edge Media Player version 1.2.0
* 
*	Author: Emanuele Manco
* 	E-Mail: hello@flashedge.net
*	Web: http://activeden.net/user/flashedge
*  
*****************************************************/

package net.flashedge.utils 
{
	import flash.geom.Point;
	
	
	public class Grid
	{
		
		public function Grid() 
		{
			
		}
		
		public static function create(columns:int, rows:int, xSpacing:int, ySpacing:int, xPadding:int, yPadding:int, leftToRight:Boolean = false):Array
		{
			var arr:Array = new Array();
			var pt:Point;
			var row:Number;
			var col:Number;
			var num:int = (columns * rows);
			
			for (var i:int = 0; i < num; i++)
			{
				pt = new Point();
				
				if (leftToRight)
				{
					row = (i % columns);
					col = Math.floor(i / columns);
				
					pt.x = (row * (xSpacing + xPadding));
					pt.y = (col * (ySpacing + yPadding));
				}
				else
				{
					row = (i % rows);
					col = Math.floor(i / rows);
				
					pt.x = (col * (xSpacing + xPadding));
					pt.y = (row * (ySpacing + yPadding));
				}
				
				arr.push(pt);
			}
			
			return arr;
		}
	}

}